<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Caffe: include/caffe/data_transformer.hpp Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Caffe
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="dir_d44c64559bbebec7f509842c48db8b23.html">include</a></li><li class="navelem"><a class="el" href="dir_4b7f3da7c7b4301d805dae0326fb91b7.html">caffe</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">data_transformer.hpp</div>  </div>
</div><!--header-->
<div class="contents">
<div class="fragment"><div class="line"><a name="l00001"></a><span class="lineno">    1</span>&#160;<span class="preprocessor">#ifndef CAFFE_DATA_TRANSFORMER_HPP</span></div><div class="line"><a name="l00002"></a><span class="lineno">    2</span>&#160;<span class="preprocessor">#define CAFFE_DATA_TRANSFORMER_HPP</span></div><div class="line"><a name="l00003"></a><span class="lineno">    3</span>&#160;</div><div class="line"><a name="l00004"></a><span class="lineno">    4</span>&#160;<span class="preprocessor">#include &lt;vector&gt;</span></div><div class="line"><a name="l00005"></a><span class="lineno">    5</span>&#160;</div><div class="line"><a name="l00006"></a><span class="lineno">    6</span>&#160;<span class="preprocessor">#include &quot;caffe/blob.hpp&quot;</span></div><div class="line"><a name="l00007"></a><span class="lineno">    7</span>&#160;<span class="preprocessor">#include &quot;caffe/common.hpp&quot;</span></div><div class="line"><a name="l00008"></a><span class="lineno">    8</span>&#160;<span class="preprocessor">#include &quot;caffe/proto/caffe.pb.h&quot;</span></div><div class="line"><a name="l00009"></a><span class="lineno">    9</span>&#160;</div><div class="line"><a name="l00010"></a><span class="lineno">   10</span>&#160;<span class="keyword">namespace </span><a class="code" href="namespacecaffe.html">caffe</a> {</div><div class="line"><a name="l00011"></a><span class="lineno">   11</span>&#160;</div><div class="line"><a name="l00016"></a><span class="lineno">   16</span>&#160;<span class="keyword">template</span> &lt;<span class="keyword">typename</span> Dtype&gt;</div><div class="line"><a name="l00017"></a><span class="lineno"><a class="line" href="classcaffe_1_1DataTransformer.html">   17</a></span>&#160;<span class="keyword">class </span><a class="code" href="classcaffe_1_1DataTransformer.html">DataTransformer</a> {</div><div class="line"><a name="l00018"></a><span class="lineno">   18</span>&#160; <span class="keyword">public</span>:</div><div class="line"><a name="l00019"></a><span class="lineno">   19</span>&#160;  <span class="keyword">explicit</span> <a class="code" href="classcaffe_1_1DataTransformer.html">DataTransformer</a>(<span class="keyword">const</span> TransformationParameter&amp; param, Phase phase);</div><div class="line"><a name="l00020"></a><span class="lineno">   20</span>&#160;  <span class="keyword">virtual</span> ~<a class="code" href="classcaffe_1_1DataTransformer.html">DataTransformer</a>() {}</div><div class="line"><a name="l00021"></a><span class="lineno">   21</span>&#160;</div><div class="line"><a name="l00026"></a><span class="lineno">   26</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1DataTransformer.html#a6d807c7dc250e66b62d97d9847278e68">InitRand</a>();</div><div class="line"><a name="l00027"></a><span class="lineno">   27</span>&#160;</div><div class="line"><a name="l00038"></a><span class="lineno">   38</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1DataTransformer.html#a1626db49587d506a91e7b70373ace816">Transform</a>(<span class="keyword">const</span> Datum&amp; datum, <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>* transformed_blob);</div><div class="line"><a name="l00039"></a><span class="lineno">   39</span>&#160;</div><div class="line"><a name="l00050"></a><span class="lineno">   50</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1DataTransformer.html#a1626db49587d506a91e7b70373ace816">Transform</a>(<span class="keyword">const</span> vector&lt;Datum&gt; &amp; datum_vector,</div><div class="line"><a name="l00051"></a><span class="lineno">   51</span>&#160;                <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>* transformed_blob);</div><div class="line"><a name="l00052"></a><span class="lineno">   52</span>&#160;</div><div class="line"><a name="l00053"></a><span class="lineno">   53</span>&#160;<span class="preprocessor">#ifdef USE_OPENCV</span></div><div class="line"><a name="l00054"></a><span class="lineno">   54</span>&#160;</div><div class="line"><a name="l00064"></a><span class="lineno">   64</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1DataTransformer.html#a1626db49587d506a91e7b70373ace816">Transform</a>(<span class="keyword">const</span> vector&lt;cv::Mat&gt; &amp; mat_vector,</div><div class="line"><a name="l00065"></a><span class="lineno">   65</span>&#160;                <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>* transformed_blob);</div><div class="line"><a name="l00066"></a><span class="lineno">   66</span>&#160;</div><div class="line"><a name="l00077"></a><span class="lineno">   77</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1DataTransformer.html#a1626db49587d506a91e7b70373ace816">Transform</a>(<span class="keyword">const</span> cv::Mat&amp; cv_img, <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>* transformed_blob);</div><div class="line"><a name="l00078"></a><span class="lineno">   78</span>&#160;<span class="preprocessor">#endif  // USE_OPENCV</span></div><div class="line"><a name="l00079"></a><span class="lineno">   79</span>&#160;</div><div class="line"><a name="l00091"></a><span class="lineno">   91</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1DataTransformer.html#a1626db49587d506a91e7b70373ace816">Transform</a>(<a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>* input_blob, <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a>* transformed_blob);</div><div class="line"><a name="l00092"></a><span class="lineno">   92</span>&#160;</div><div class="line"><a name="l00100"></a><span class="lineno">  100</span>&#160;  vector&lt;int&gt; <a class="code" href="classcaffe_1_1DataTransformer.html#a1e43b0fb80cded5bb854e1a06004bebf">InferBlobShape</a>(<span class="keyword">const</span> Datum&amp; datum);</div><div class="line"><a name="l00109"></a><span class="lineno">  109</span>&#160;  vector&lt;int&gt; <a class="code" href="classcaffe_1_1DataTransformer.html#a1e43b0fb80cded5bb854e1a06004bebf">InferBlobShape</a>(<span class="keyword">const</span> vector&lt;Datum&gt; &amp; datum_vector);</div><div class="line"><a name="l00118"></a><span class="lineno">  118</span>&#160;<span class="preprocessor">#ifdef USE_OPENCV</span></div><div class="line"><a name="l00119"></a><span class="lineno">  119</span>&#160;  vector&lt;int&gt; <a class="code" href="classcaffe_1_1DataTransformer.html#a1e43b0fb80cded5bb854e1a06004bebf">InferBlobShape</a>(<span class="keyword">const</span> vector&lt;cv::Mat&gt; &amp; mat_vector);</div><div class="line"><a name="l00127"></a><span class="lineno">  127</span>&#160;  vector&lt;int&gt; <a class="code" href="classcaffe_1_1DataTransformer.html#a1e43b0fb80cded5bb854e1a06004bebf">InferBlobShape</a>(<span class="keyword">const</span> cv::Mat&amp; cv_img);</div><div class="line"><a name="l00128"></a><span class="lineno">  128</span>&#160;<span class="preprocessor">#endif  // USE_OPENCV</span></div><div class="line"><a name="l00129"></a><span class="lineno">  129</span>&#160;</div><div class="line"><a name="l00130"></a><span class="lineno">  130</span>&#160; <span class="keyword">protected</span>:</div><div class="line"><a name="l00139"></a><span class="lineno">  139</span>&#160;  <span class="keyword">virtual</span> <span class="keywordtype">int</span> <a class="code" href="classcaffe_1_1DataTransformer.html#ac3e52731074a73b05ff0527d2febc8f2">Rand</a>(<span class="keywordtype">int</span> n);</div><div class="line"><a name="l00140"></a><span class="lineno">  140</span>&#160;</div><div class="line"><a name="l00141"></a><span class="lineno">  141</span>&#160;  <span class="keywordtype">void</span> <a class="code" href="classcaffe_1_1DataTransformer.html#a1626db49587d506a91e7b70373ace816">Transform</a>(<span class="keyword">const</span> Datum&amp; datum, Dtype* transformed_data);</div><div class="line"><a name="l00142"></a><span class="lineno">  142</span>&#160;  <span class="comment">// Tranformation parameters</span></div><div class="line"><a name="l00143"></a><span class="lineno">  143</span>&#160;  TransformationParameter param_;</div><div class="line"><a name="l00144"></a><span class="lineno">  144</span>&#160;</div><div class="line"><a name="l00145"></a><span class="lineno">  145</span>&#160;</div><div class="line"><a name="l00146"></a><span class="lineno">  146</span>&#160;  shared_ptr&lt;Caffe::RNG&gt; rng_;</div><div class="line"><a name="l00147"></a><span class="lineno">  147</span>&#160;  Phase phase_;</div><div class="line"><a name="l00148"></a><span class="lineno">  148</span>&#160;  <a class="code" href="classcaffe_1_1Blob.html">Blob&lt;Dtype&gt;</a> data_mean_;</div><div class="line"><a name="l00149"></a><span class="lineno">  149</span>&#160;  vector&lt;Dtype&gt; mean_values_;</div><div class="line"><a name="l00150"></a><span class="lineno">  150</span>&#160;};</div><div class="line"><a name="l00151"></a><span class="lineno">  151</span>&#160;</div><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;}  <span class="comment">// namespace caffe</span></div><div class="line"><a name="l00153"></a><span class="lineno">  153</span>&#160;</div><div class="line"><a name="l00154"></a><span class="lineno">  154</span>&#160;<span class="preprocessor">#endif  // CAFFE_DATA_TRANSFORMER_HPP_</span></div><div class="ttc" id="namespacecaffe_html"><div class="ttname"><a href="namespacecaffe.html">caffe</a></div><div class="ttdoc">A layer factory that allows one to register layers. During runtime, registered layers can be called b...</div><div class="ttdef"><b>Definition:</b> blob.hpp:14</div></div>
<div class="ttc" id="classcaffe_1_1DataTransformer_html_a1e43b0fb80cded5bb854e1a06004bebf"><div class="ttname"><a href="classcaffe_1_1DataTransformer.html#a1e43b0fb80cded5bb854e1a06004bebf">caffe::DataTransformer::InferBlobShape</a></div><div class="ttdeci">vector&lt; int &gt; InferBlobShape(const Datum &amp;datum)</div><div class="ttdoc">Infers the shape of transformed_blob will have when the transformation is applied to the data...</div><div class="ttdef"><b>Definition:</b> data_transformer.cpp:442</div></div>
<div class="ttc" id="classcaffe_1_1DataTransformer_html"><div class="ttname"><a href="classcaffe_1_1DataTransformer.html">caffe::DataTransformer</a></div><div class="ttdoc">Applies common transformations to the input data, such as scaling, mirroring, substracting the image ...</div><div class="ttdef"><b>Definition:</b> data_transformer.hpp:17</div></div>
<div class="ttc" id="classcaffe_1_1DataTransformer_html_a6d807c7dc250e66b62d97d9847278e68"><div class="ttname"><a href="classcaffe_1_1DataTransformer.html#a6d807c7dc250e66b62d97d9847278e68">caffe::DataTransformer::InitRand</a></div><div class="ttdeci">void InitRand()</div><div class="ttdoc">Initialize the Random number generations if needed by the transformation. </div><div class="ttdef"><b>Definition:</b> data_transformer.cpp:523</div></div>
<div class="ttc" id="classcaffe_1_1DataTransformer_html_ac3e52731074a73b05ff0527d2febc8f2"><div class="ttname"><a href="classcaffe_1_1DataTransformer.html#ac3e52731074a73b05ff0527d2febc8f2">caffe::DataTransformer::Rand</a></div><div class="ttdeci">virtual int Rand(int n)</div><div class="ttdoc">Infers the shape of transformed_blob will have when the transformation is applied to the data...</div><div class="ttdef"><b>Definition:</b> data_transformer.cpp:535</div></div>
<div class="ttc" id="classcaffe_1_1DataTransformer_html_a1626db49587d506a91e7b70373ace816"><div class="ttname"><a href="classcaffe_1_1DataTransformer.html#a1626db49587d506a91e7b70373ace816">caffe::DataTransformer::Transform</a></div><div class="ttdeci">void Transform(const Datum &amp;datum, Blob&lt; Dtype &gt; *transformed_blob)</div><div class="ttdoc">Applies the transformation defined in the data layer&amp;#39;s transform_param block to the data...</div><div class="ttdef"><b>Definition:</b> data_transformer.cpp:131</div></div>
<div class="ttc" id="classcaffe_1_1Blob_html"><div class="ttname"><a href="classcaffe_1_1Blob.html">caffe::Blob</a></div><div class="ttdoc">A wrapper around SyncedMemory holders serving as the basic computational unit through which Layers...</div><div class="ttdef"><b>Definition:</b> blob.hpp:24</div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated on Thu Aug 3 2017 23:11:19 for Caffe by &#160;<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/>
</a> 1.8.13
</small></address>
</body>
</html>
